package com.doit.day03

object _07_元祖 {
  def main(args: Array[String]): Unit = {
    //元祖就是一个类  Tuple
    val tuple: Tuple1[Int] = new Tuple1[Int](1)

    val tuple1: (Int, String, Double) = new Tuple3[Int, String, Double](1, "zss", 10.9)


    //7元元祖
    val tuple2: (Int, String, Double, Boolean, Char, Int, Array[Int]) = (1, "zss", 10.8, true, 'a', 10, Array(1, 2, 3))


    //new Person id  name  age  gender
    val tuple3: (Int, String, Int, String) = (1, "zss", 18, "male")

    //获取元祖里面的值
    println(tuple3._1)
    println(tuple3._2)
    println(tuple3._3)
    println(tuple3._4)


    //两个元素的元祖  二元元祖  ==》 对偶元祖  key value
    val tuple4: (String, String) = ("name", "zss")


    //    Map集合  HashMap
    val map: Map[String, Int] = Map("zss" -> 18, "lss" -> 20)
    val map1: Map[String, Int] = Map(("zss", 19), ("lss", 20), ("www", 10), ("biandan", 4))
    for (elem <- map) {
      val key: String = elem._1
      val value: Int = elem._2
    }

//    val stringToInt: Map[String, Int] = map.updated("zss", 90);

    val maybeInt: Option[Int] = map.get("zss1")
    if(maybeInt.isDefined){
      val value: Int = maybeInt.get
      println(value)
    }else{
      println("这个可以不存在啦")
    }

    //java中hashMap有没有一个方法叫getOrDefault
    val i: Int = map.getOrElse("zss1", 0)
    println(i)




  }
}
